﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;

namespace DAL
{
    /// <summary>
    ///  楼状况勘查表
    /// </summary>
    public class FloorsDal : BaseDal<Model.EAFloors>
    {
        public override string tablename
        {
            get { return "EAFloors"; }
        }

        public override Dictionary<string, bool> PKName
        {
            get
            {

                Dictionary<string, bool> dic = new Dictionary<string, bool>();
                dic.Add("floor_Id", true);
                return dic;
            }
        }
        /// <summary>
        /// 楼况勘察反填
        /// </summary>
        /// <param name="pro"></param>
        /// <returns></returns>
        public List<EAFloors> GetListByPro(string pro)
        {
            string sql = "select * from EAFloors where ProjectNumber='" + pro + "' ";
            return DBHelper.ExecuteObjects<EAFloors>(sql);
        }
        /// <summary>
        /// 判断项目号是否唯一
        /// </summary>
        /// <param name="pro"></param>
        /// <returns></returns>
        public int GetCount(string pro)
        {
            string sql = "select count(*) from EAFloors where ProjectNumber='" + pro + "' ";
            return (int)DBHelper.ExecuteScalar(sql);
        }
        /// <summary>
        /// 根据项目编号修改
        /// </summary>
        /// <param name="t"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Update(EAFloors floor) 
        {
            string sql = "UPDATE [House].[dbo].[EAFloors] SET [Floor_Number] = '"+floor.floor_Number+"',[Floor_Landmark] = '"+floor.floor_Landmark+"' ,[Floor_Address] = '"+floor.floor_Address+"' ,[Floor_HouseStructure] = '"+floor.floor_HouseStructure+"' ,[Floor_BuildType] = '"+floor.floor_BuildType+"' ,[Floor_Facade] = '"+floor.floor_Facade+"' ,[Floor_Public] = '"+floor.floor_Public+"' ,[Floor_Lift] = '"+floor.floor_Lift+"' ,[Floor_LiftNum] = '"+floor.floor_LiftNum+"' ,[Floor_Gas] = '"+floor.floor_Gas+"' ,[Floor_Water] = '"+floor.floor_Water+"',[Floor_Warm] = '"+floor.floor_Warm+"',[Floor_Door] = '"+floor.floor_Door+"',[Floor_Explain] = '"+floor.floor_Explain+"' WHERE ProjectNumber='"+floor.projectNumber+"' ";
            return DBHelper.ExecuteNonQuery(sql) > 0;
        }
    }
}
